package com.mlnx.device.util;

import com.alibaba.fastjson.JSON;
import com.mlnx.device.tool.HumpTool;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class SortUtil {

    public static Map<String, String> parseSorter(String sorter) {
        if (sorter == null || sorter.isEmpty())
            return null;

        Map<String, String> map = JSON.parseObject(sorter, Map.class);

        if (map != null && map.size() > 0) {
            Map<String, String> temp = new HashMap<>();
            Set<String> keys = map.keySet();
            for (String key : keys) {
                temp.put(HumpTool.humpToLine(key), map.get(key));
            }

            return temp;
        }

        return null;
    }
}
